#import guiqwt.pyplot as plt
import matplotlib.pyplot as plt
import numpy as np

fs = 44100 

fp=open('1419862307_44100_ch2.int16','rb')
buf=fp.read()

wave = np.fromstring(buf,dtype=np.int16)
wave -= wave.mean()

wave1 = wave[::2]
wave1 = wave1[:32768]
wave1 -= wave1.mean()
t1 =np.arange(len(wave1))/float(fs)

plt.figure()
plt.subplot(211)
plt.plot(t1,wave1)
plt.subplot(212)
plt.psd(wave1/wave1.max(),Fs=fs,NFFT=4096)

wave2 = wave[1::2]
wave2 = wave2[:32768]
wave2 -= wave2.mean()
t2 =np.arange(len(wave2))/float(fs)

plt.figure()
plt.subplot(211)
plt.plot(t2,wave2)
plt.subplot(212)
plt.psd(wave2/wave2.max(),Fs=fs,NFFT=4096)

print wave1[0:10]
print wave2[0:10]

plt.show()


